package CourseServlet;

import Course.CourseDao;
import Worker.WorkerDao;
import Worker.WorkerEnity;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "updateCourseServlet")
public class updateCourseServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        CourseDao courseDao=new CourseDao();
        String courseNo=request.getParameter("courseNo");
        String courseName=request.getParameter("courseName");
        float credit=Float.parseFloat(request.getParameter("credit"));
        String classRoom=request.getParameter("classRoom");
        int classHour=Integer.parseInt(request.getParameter("classHour"));
        int row=courseDao.updateCourse(courseNo,courseName,credit,classRoom,classHour);
        if(row>0){
            response.sendRedirect("/educateOffice/CourseMangement.jsp?courseNo="+courseNo);
        }else {
            response.getWriter().println("修改出错,请退后重试");
        }
    }
}
